package com.ljt.kotlinandmvvm.main.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.ljt.base.fragment.BaseFragment
import com.ljt.kotlinandmvvm.R
import com.ljt.kotlinandmvvm.databinding.FragmentFirstBinding
import com.ljt.kotlinandmvvm.databinding.FragmentFoodBinding
import com.ljt.kotlinandmvvm.databinding.FragmentShoppingCartBinding
import com.ljt.kotlinandmvvm.main.adapter.ShoppingCartAdapter
import kotlinx.android.synthetic.main.draw_module_title.view.*

/**
 * @auther :lujiantao
 * @date :2024/4/29 12:37 PM
 * @desc :购物车
 */
class ShoppingCartFragment: BaseFragment() {

    private lateinit var binding: FragmentShoppingCartBinding
    var listStr:ArrayList<String> = ArrayList()
    lateinit var adapter:ShoppingCartAdapter

    companion object{
        fun newInstance() = ShoppingCartFragment()
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentShoppingCartBinding.inflate(layoutInflater) // 缺失的是这一行
        initView()
        return binding.root
    }


    fun initView() {
        if (binding != null) {
            binding.ilModuleTitle.tvModuleTitle.text = "购物车"
            binding.ilModuleTitle.ivModuleBack.visibility = View.GONE
            //创建假数据
            listStr.add("神仙鸡")
            listStr.add("神仙豆腐")
            listStr.add("蹄花")
            listStr.add("猪脚面")
            binding.rlModule.layoutManager = LinearLayoutManager(binding.rlModule.context)
            adapter = ShoppingCartAdapter(listStr)
            binding.rlModule.adapter = adapter
        }
    }
}